import { defineComponent, onBeforeMount, reactive, ref } from "vue";
import CommonApi from "/@/api/CommonApi";

const CommonTest = defineComponent({
  name: "CommonTest",
  setup(props) {
    const CommonObj = reactive({
      tableHead: []
    });
    const commonApi = new CommonApi();
    // 获取基表信息用于格式化下拉框及表格数据
    const acquireTableInfo = async (tableAlias: any) => {
      // CommonObj.loading = true;
      await commonApi.getTableInfo(tableAlias).then(ref => {
        if (ref.data.code === 0) {
          CommonObj.tableHead = ref.data.data.fieldList;
          // CommonObj.primaryKey = ref.data.data.tablePk;
        }
      });
    };
    onBeforeMount(async () => {
      await acquireTableInfo(props.tableAlias);
    });
    return {
      CommonObj
    };
  }
});

export default CommonTest;
